package com.jetpackframework.room;

import android.content.ContentValues;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteTransactionListener;
import android.os.CancellationSignal;
import android.util.Log;
import android.util.Pair;

import androidx.sqlite.db.SupportSQLiteDatabase;
import androidx.sqlite.db.SupportSQLiteQuery;
import androidx.sqlite.db.SupportSQLiteStatement;

import net.sqlcipher.database.SQLiteDatabase;

import java.io.IOException;
import java.util.List;
import java.util.Locale;


public class SqliteDatabase implements SupportSQLiteDatabase {

    private SQLiteDatabase database;

    public SqliteDatabase(SQLiteDatabase database) {
        this.database = database;
    }

    @Override
    public SupportSQLiteStatement compileStatement(String sql) {
        return database.compileStatement(sql);
    }

    @Override
    public void beginTransaction() {
        database.beginTransaction();
    }

    @Override
    public void beginTransactionNonExclusive() {
        database.beginTransactionNonExclusive();
    }

    @Override
    public void beginTransactionWithListener(SQLiteTransactionListener transactionListener) {
        database.beginTransactionWithListener(transactionListener);
    }

    @Override
    public void beginTransactionWithListenerNonExclusive(SQLiteTransactionListener transactionListener) {
        database.beginTransactionWithListenerNonExclusive(transactionListener);
    }

    @Override
    public void endTransaction() {
        database.endTransaction();
    }

    @Override
    public void setTransactionSuccessful() {
        database.setTransactionSuccessful();
    }

    @Override
    public boolean inTransaction() {
        return database.inTransaction();
    }

    @Override
    public boolean isDbLockedByCurrentThread() {
        return database.isDbLockedByCurrentThread();
    }

    @Override
    public boolean yieldIfContendedSafely() {
        return database.yieldIfContendedSafely();
    }

    @Override
    public boolean yieldIfContendedSafely(long sleepAfterYieldDelay) {
        return database.yieldIfContendedSafely(sleepAfterYieldDelay);
    }

    @Override
    public int getVersion() {
        return database.getVersion();
    }

    @Override
    public void setVersion(int version) {
        database.setVersion(version);
    }

    @Override
    public long getMaximumSize() {
        return database.getMaximumSize();
    }

    @Override
    public long setMaximumSize(long numBytes) {
        return database.setMaximumSize(numBytes);
    }

    @Override
    public long getPageSize() {
        return database.getPageSize();
    }

    @Override
    public void setPageSize(long numBytes) {
        database.setPageSize(numBytes);
    }

    @Override
    public Cursor query(String query) {
        return database.query(query);
    }

    @Override
    public Cursor query(String query, Object[] bindArgs) {
        return database.query(query, bindArgs);
    }

    @Override
    public Cursor query(SupportSQLiteQuery query) {
        return database.query(query);
    }

    @Override
    public Cursor query(SupportSQLiteQuery query, CancellationSignal cancellationSignal) {
        return database.query(query, cancellationSignal);
    }

    @Override
    public long insert(String table, int conflictAlgorithm, ContentValues values) throws SQLException {
        return database.insert(table, conflictAlgorithm, values);
    }

    @Override
    public int delete(String table, String whereClause, Object[] whereArgs) {
        return database.delete(table, whereClause, whereArgs);
    }

    @Override
    public int update(String table, int conflictAlgorithm, ContentValues values, String whereClause, Object[] whereArgs) {
        return database.update(table, conflictAlgorithm, values, whereClause, whereArgs);
    }

    @Override
    public void execSQL(String sql) throws SQLException {
        database.execSQL(sql);
        Log.e("TAG---",sql);
    }

    @Override
    public void execSQL(String sql, Object[] bindArgs) throws SQLException {
        database.execSQL(sql,bindArgs);
        Log.e("TAG---",sql);
    }

    @Override
    public boolean isReadOnly() {
        return database.isReadOnly();
    }

    @Override
    public boolean isOpen() {
        return database.isOpen();
    }

    @Override
    public boolean needUpgrade(int newVersion) {
        return database.needUpgrade(newVersion);
    }

    @Override
    public String getPath() {
        return database.getPath();
    }

    @Override
    public void setLocale(Locale locale) {
        database.setLocale(locale);
    }

    @Override
    public void setMaxSqlCacheSize(int cacheSize) {
        database.setMaxSqlCacheSize(cacheSize);
    }

    @Override
    public void setForeignKeyConstraintsEnabled(boolean enable) {
        database.setForeignKeyConstraintsEnabled(enable);
    }

    @Override
    public boolean enableWriteAheadLogging() {
        return database.enableWriteAheadLogging();
    }

    @Override
    public void disableWriteAheadLogging() {
        database.disableWriteAheadLogging();
    }

    @Override
    public boolean isWriteAheadLoggingEnabled() {
        return database.isWriteAheadLoggingEnabled();
    }

    @Override
    public List<Pair<String, String>> getAttachedDbs() {
        return database.getAttachedDbs();
    }

    @Override
    public boolean isDatabaseIntegrityOk() {
        return database.isDatabaseIntegrityOk();
    }

    @Override
    public void close() throws IOException {
        database.close();
    }
}
